package com.hulk.dryad.activiti7.listener;


import com.hulk.dryad.common.util.SpringContextHolder;
import com.hulk.dryad.persistence.entity.WorkflowLeave;
import com.hulk.dryad.activiti7.service.IWorkflowLeaveService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;


/**
 * @author hulk
 */
public class LeaveEndStateListener implements ExecutionListener {

    private Expression state;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        WorkflowLeave workflowLeave = new WorkflowLeave();
        workflowLeave.setId(delegateExecution.getProcessInstanceBusinessKey());
        workflowLeave.setState(state.getValue(delegateExecution).toString());
        SpringContextHolder.getBean(IWorkflowLeaveService.class).updateWorkflowLeave(workflowLeave);
    }
}
